import store from './store'
import router from './router'
import {Error} from "./utils/notify";

const white = ['Login', 'Index','Register','Home']
router.beforeEach(async(to,from,next)=>{
    if(white.indexOf(to.name) > -1){
        next()
    }else {
        let isLogin = localStorage.getItem('isLogin')  || 0;
        if(isLogin == 1){
            await store.dispatch('user/getUserInfo')
            next()
        }else {
            Error('请先登录！')
            next({name:'Login'})

        }
    }
})